<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>空白字符检测</title>
    <style>
        body {
            font-family: 'Arial', sans-serif;
            background-color: #f4f7fc;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
        }

        .container {
            background-color: #ffffff;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
            width: 100%;
            max-width: 400px;
            text-align: center;
        }

        h1 {
            font-size: 24px;
            color: #333;
            margin-bottom: 20px;
        }

        input[type="text"] {
            width: 100%;
            padding: 10px;
            font-size: 16px;
            margin-bottom: 15px;
            border: 1px solid #ccc;
            border-radius: 4px;
        }

        button {
            padding: 10px 20px;
            font-size: 16px;
            color: white;
            background-color: #4CAF50;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }

        button:hover {
            background-color: #45a049;
        }

        .result {
            margin-top: 20px;
            font-size: 18px;
            font-weight: bold;
        }

        .yes {
            color: green;
        }

        .no {
            color: red;
        }
    </style>
</head>

<body>
    <div class="container">
        <h1>检查文本中是否包含空白字符</h1>
        <input type="text" id="textInput" placeholder="请输入文本...">
        <button onclick="checkWhitespace()">检查</button>
        <div id="result" class="result"></div>
    </div>

    <script>
        // 检测是否包含空白字符的函数
        const containsWhitespace = str => /\s/.test(str);

        function checkWhitespace() {
            const inputText = document.getElementById('textInput').value;
            const resultElement = document.getElementById('result');

            if (containsWhitespace(inputText)) {
                resultElement.textContent = '该文本包含空白字符。';
                resultElement.className = 'result yes';
            } else {
                resultElement.textContent = '该文本不包含空白字符。';
                resultElement.className = 'result no';
            }
        }
    </script>
</body>

</html>